﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Maticsoft.Common;
using Maticsoft.Common.DEncrypt;

namespace Maticsoft.Web.wap
{
    public partial class UserPwd : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Check();

            ProcessAjax();
        }

        protected void ProcessAjax()
        {
            if (Request.QueryString["sync"] == "true")
            {
                if (Request.QueryString["ope"] == "mod")
                {
                    Response.Write(ModifyPwd());
                    Response.End();
                }
            }
        }

        protected string ModifyPwd()
        {
            BLL.Members meBLL = new BLL.Members();
            Model.Members meModel = meBLL.GetModel(DigitHelper.GetInt32(this.UserId));
            string oldPwd = Request.QueryString["o"];
            string newPwd = Request.QueryString["n"];
            oldPwd = DEncrypt.Encrypt(oldPwd);
            newPwd = DEncrypt.Encrypt(newPwd);
            if (oldPwd != meModel.Password)
            {
                return "-1";
            }

            meModel.Password = newPwd;
            meModel.UpdateTime = DateTime.Now;
            meBLL.Update(meModel);

            return "1";
        }
    }
}